package model;

import java.io.Serializable;
import java.util.ArrayList;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;


@XmlRootElement(name = "group")
public class Group extends Link implements Serializable
{
	private static final long serialVersionUID = -6799751897822416444L;

	private static int i = 0;
	
	@XmlAttribute
	private String id = "";
	
	@XmlAttribute
	private String name = "";
	
	@XmlAttribute
	private String description = "";
	
	@XmlElement(name = "day")
	private ArrayList<Day> days = new ArrayList<Day>();
	
	public Group() {}
	
	public Group(String name)
	{
		i++;
		this.id = i + "";
		this.name = name;
	}
	
	public Group(String name, String description)
	{
		i++;
		this.id = i + "";
		this.name = name;
		this.description = description;
	}
	
	public String toString()
	{
		String out = "\n";
		for (int i = 0; i < days.size(); i++)
		{
			out += days.get(i) + "\n";
		}
		return "Group id(" + id + ") -> Name: " + name + " Description: " + description + "\n" + out;
	}
	
	public Day createDay(String name)
	{
		Day day = new Day(name);
		days.add(day);
		return day;
	}

	public ArrayList<Day> getDays()
	{
		return days;
	}
	
	public String getName()
	{
		return name;
	}

	public String getDescription()
	{
		return description;
	}

	public String getId()
	{
		return id;
	}

	public void setId(String id)
	{
		this.id = id;
	}
}